how to chain rule with three functions